Imagegick
Overview
In this documentation, Imagegick refers to ImageMagick: an open-source suite for creating, converting, and transforming bitmap images from the command line and via libraries. It’s commonly used to automate image workflows such as resizing, format conversion, metadata stripping, thumbnails, and compositing.
The upstream project name is ImageMagick. Examples and commands below use the upstream naming to match the actual binaries and manual pages.
History
- 1987: Created by John Cristy (initially to convert high-color images to formats usable on common displays).
- 1990: Released publicly after DuPont transferred copyright to ImageMagick Studio LLC.
- Ongoing development includes a major CLI and pipeline modernization in ImageMagick 7.
Adoption
ImageMagick is widely used in:
- Web backends that process user uploads (thumbnails, normalization, transformations)
- CI/CD pipelines and content build systems (batch conversions and optimization)
- Language ecosystems and wrappers (for example, PHP Imagick and Ruby libraries commonly used with ImageMagick)
Maintainer
Maintained by ImageMagick Studio LLC (with John Cristy as the principal architect/maintainer in project materials).
Best when to use
- Automating repeatable image tasks in scripts and pipelines
- Batch processing large sets of files with consistent transforms
- Running server-side image normalization (size, format, metadata, colorspace)
- Integrating image transforms into application code via libraries/bindings
Not suitable when
- You need fully interactive editing with non-destructive layers and design workflows
- You must process untrusted uploads but cannot apply sandboxing, resource limits, and a restrictive security policy
- You need strict, deterministic output across heterogeneous builds without controlling versions and delegates
Compatibility notes
- ImageMagick 7 uses
magickas the primary entry point; legacyconvert-style parsing is deprecated in IM7 workflows. - Windows: Avoid
convert(it conflicts with a Windows system tool). Prefermagickconsistently across platforms. - Linux distributions may ship different major versions (IM6 vs IM7). Always verify the installed version after installation.
Focus: operational command-line usage of ImageMagick for safe inspection, common transforms, batch workflows, troubleshooting, and security hardening.
Concepts and how it works
ImageMagick commands form a pipeline:
- Read one or more input images
- Apply a sequence of operations (order matters)
- Write output images
Key points:
-
Options generally apply in the order they appear.
-
Many operations are in-memory; large images can consume significant RAM without limits.
-
Batch tools differ in behavior:
magickwrites new outputs by default.mogrifycan overwrite inputs (use carefully).
Installation
Verify before installing (read-only)
magick -version
If installed, also check supported formats and delegates:
magick -list format | head
magick -list delegate | head
Install (common package managers)
- Linux
- macOS
- Windows
Debian/Ubuntu
sudo apt update
sudo apt install imagemagick
Fedora/RHEL family
sudo dnf install ImageMagick
Arch
sudo pacman -S imagemagick
Some distro repositories may package IM6 while others provide IM7. Always confirm with magick -version and adjust scripts accordingly.
brew install imagemagick
Winget
winget install -e --id ImageMagick.ImageMagick
After installation, open a new terminal and verify:
magick -version
On Windows, calling magick identify ... is the most reliable pattern when direct tool names are not on PATH.
Common commands and options
Basic syntax
magick [input(s)] [operations...] output
In ImageMagick 7, prefer magick without convert:
magick input.png output.jpg
Using magick convert ... may produce a deprecation warning in IM7. Prefer magick ... for new scripts.
Inspect image properties (safe, read-only)
Get quick info:
magick identify input.jpg
Custom format output (useful in scripts):
magick identify -format "%m %w %h %b\n" input.jpg
Verbose inspection:
magick identify -verbose input.jpg | head -n 50
Convert formats
PNG to JPEG:
magick input.png output.jpg
JPEG quality control:
magick input.png -quality 85 output.jpg
Resize safely
Resize to fit within bounds (never upscale):
magick input.jpg -resize 1200x1200\> output.jpg
Create a square thumbnail (crop to fill):
magick input.jpg -thumbnail 256x256^ -gravity center -extent 256x256 output.jpg
Crop
magick input.jpg -crop 300x200+10+20 +repage output.jpg
Strip metadata (privacy and size)
magick input.jpg -strip output.jpg
Add a text watermark
magick input.jpg \
-gravity southeast -pointsize 24 -fill white -stroke black -strokewidth 1 \
-annotate +12+12 "Example" \
output.jpg
Batch processing
Safe batch: write to a new directory
mkdir -p out
magick mogrify -path out -resize 1600x1600\> -strip *.jpg
mogrify can overwrite the original files if you omit -path (or use other overwriting patterns). Prefer writing to a separate output directory until you’ve validated results.
Batch convert extension (copying, not overwriting)
for f in *.png; do
magick "$f" "${f%.png}.jpg"
done
Practical use cases
Web upload normalization pipeline
A common pattern is to normalize format, size, and metadata:
magick input.jpg \
-auto-orient \
-resize 2048x2048\> \
-strip \
-quality 85 \
output.jpg
Create a contact sheet
magick montage *.jpg -geometry 200x200+4+4 -tile 5x out.png
Create an animated GIF from frames
magick -delay 8 -loop 0 frame-*.png out.gif
Troubleshooting
not authorized / security policy errors
Symptoms often look like:
- “attempt to perform an operation not allowed by the security policy”
Check the effective policy:
magick -list policy
If you require reading/writing a format that is blocked, adjust policy carefully (see Security notes).
no decode delegate for this image format
This typically indicates missing format support in the installed build.
Check whether a format is supported for read/write:
magick -list format | grep -E 'PNG|JPEG|WEBP|HEIC' || true
If the format is missing, install a build that includes the required delegates (distro packages often vary by policy and dependencies).
Slow processing or high memory usage
List current resource limits:
magick -limit list
Apply per-command limits for safer operation:
magick -limit memory 256MiB -limit map 512MiB -limit time 30 \
input.jpg -resize 2000x2000\> output.jpg
Security notes
Image processing can be high-risk when handling untrusted user uploads. ImageMagick has had critical vulnerabilities (commonly referenced as “ImageTragick”), and secure deployments rely on isolation and policy controls.
If your application accepts user-supplied images, combine a restrictive policy.xml, resource limits (-limit), and sandboxing (container/jail/low-privilege user) before processing.
Recommended baseline controls:
- Enforce strict resource limits (time, memory, disk, pixel area) via
-limitor policy. - Restrict allowed formats to the minimum required (for example, JPEG/PNG/WebP only).
- Disable risky coders/delegates you do not need (PDF/PS/EPS/SVG can introduce extra parsers and delegates).
- Run ImageMagick in a sandboxed environment with minimal filesystem access.
Policy configuration is environment-specific. Use the project’s security policy guidance and verify the effective policy with magick -list policy.
Quick reference
| Task | Command |
|---|---|
| - | |
| Check version | magick -version |
| Identify image | magick identify input.jpg |
| Convert format | magick input.png output.jpg |
| Resize (no upscale) | magick input.jpg -resize 1200x1200\> output.jpg |
| Square thumbnail | magick input.jpg -thumbnail 256x256^ -gravity center -extent 256x256 output.jpg |
| Crop | magick input.jpg -crop 300x200+10+20 +repage output.jpg |
| Strip metadata | magick input.jpg -strip output.jpg |
| Batch resize to folder | magick mogrify -path out -resize 1600x1600\> -strip *.jpg |